<?php
include 'headers.php';
//print_r($_POST);
//die();
// [post_id] == [news_id]
//Array ( [reply_id] => 20 [post_id] => 151 [num_reply] => 20 )

$i = $_POST['num_reply'];

$res = $db->select_query('SELECT reply_id, news_id, reply_details, cr_by, cr_date, cr_ip FROM news_reply WHERE news_id =' . $db->antihack($_POST['post_id']) . ' AND reply_id > ' . $db->antihack($_POST['reply_id']) . ' ORDER BY reply_id ASC LIMIT 10');

$countRow = mysql_num_rows($res);
if($countRow != 0)
{
    while($reply = $db->fetch($res))
    {
        ?>                           
        <div class="countReply" data-ctype='reply_news' data-newsid='<?php echo $reply['news_id']; ?>' data-replyid='<?php echo $reply['reply_id']; ?>' data-numreply='<?php echo++$i; ?>'>
            <div class="reply_status" id="reply_status" >
                <div id="pic_user" class="pic_user"><img src="images/pic_user.png" width="45" height="45" /></div>
                <div id="count_comment" style="float:right">ความคิดเห็นที่&nbsp;&nbsp;<?php echo $i; ?> </div>
                <span class="cr_by"><?php echo $reply['cr_by'] . '<br>'; ?> </span>
                <?php
                $temp = explode(' ', $reply['cr_date']);

                $tempDate = explode('-', $temp['0']);
                $day = $tempDate['2'];
                $month = $tempDate['1'];
                $year = $tempDate['0'];

                $time = $temp['1'];

                $date_time = $day . ' ' . getMonthName($month) . ' ' . ($year + 543) . ' - ' . $time;
                ?>
                <span class="cr_date"><?php echo '<strong>เมื่อ : </strong>' . $date_time . '<br><strong>&nbsp;&nbsp;&nbsp;ไอพี : </strong>' . $reply['cr_ip']; ?> </span>
            </div>

            <div class="reply_details" id="reply_detail"> <br /><?php echo $reply['reply_details']; ?><br />
                <div id="link_top_page" align="right">
                    <span class="cr_date">
                        <a class="ui-link" href="#top"><img src="images/up_to_page_icon.png" width="16" height="16" />ขึ้นบนสุด</a> 
                    </span>
                </div>
            </div>
            <div>&nbsp;</div>
        </div>
        <?php
    }
}
else
{
    echo '0';
}
?>